{include file="public/adminhead"}

<div class="container-fluid">

  <div class="row">
    <div class="card">
      <div class="card-body">

        <form class="form-horizontal" action="#" method="post" enctype="multipart/form-data" onsubmit="return false;">


          {if $res}
          <input type="hidden" name="id" value="{$res.id}">
          {/if}

          <div class="form-group">
            <label class="col-xs-12" >名称</label>
            <div class="col-xs-12">
              <input class="form-control" type="text" {if $res}value="{$res.title}"{/if} name="title" placeholder="..">
            </div>
          </div>
          <div class="form-group">
            <label class="col-xs-12" >内容</label>
            <div class="col-xs-12">
              <textarea class="form-control" name="content" rows="30" placeholder="内容..">{if $res}{$res.content}{/if} </textarea>
            </div>
          </div>


          <div class="form-group">
            <div class="col-xs-12">
              <button class="btn btn-primary" type="button" onclick="sub()">提交</button>
            </div>
          </div>
        </form>

      </div>
    </div>
  </div>

</div>

{include file="public/afooter"}

<script>
function sub() {
    var formdata = $("form").serialize();
    var url = "{:url('save')}";
    $.post(url,formdata,function (e) {
      if(e.code == 200){
          success("成功");
          var index = parent.layer.getFrameIndex(window.name);
          setTimeout(function(){parent.layer.close(index)}, 2000);
          window.parent.location.reload();
      }else {
          error(e.msg);
      }
    })
}
</script>